Computer languages offer a multitude of different ways to create aggregate types. For example, languages such as Java offer heterogeneous aggregates with identity (e.g. “classes”) and homogenous aggregates with identity (e.g. “arrays”). Identity is implemented by header information that is included with each instantiated object, such as an identification number (e.g. memory address) that uniquely identifies the object. However, object identity has footprint and performance costs, which is a major reason Java has primitive types that are stored in place, are passed by value without using a reference during method invocations, and do not include a header. This is opposed to reference types, which are accessed by a pointer, are represented using references which are passed by value during method invocations, and include a header. The cost of supporting identity is most burdensome for small objects, which do not have many fields to amortize the extra costs required to support identity.
For example, consider a Point class which has x and y fields of type int. In an implementation, an array of Point objects that each could include an extra object header (8 to 16 bytes) and a reference (4 to 8 bytes), meaning those 8 bytes of data (for the x and y integers) take up 20 to 32 bytes of heap space. Furthermore, iterating through this array means a pointer dereference for every Point object that is visited. This destroys the inherent locality of arrays and limits program performance.
Programmers often resort to tricks like representing an array of points as two arrays of ints (one for x and one for y) to avoid these costs, but this approach sacrifices encapsulation (and maintainability) just to reclaim the performance lost to identity. One approach is to significantly expand the number of primitives supported by the language. However, it can be difficult (if not impossible) to anticipate the primitive types that would be required to efficiently solve every problem put before a programmer. As a result, a construct which falls between the realms of primitive types and objects would be a great benefit to programmers.